/*
 *   Copyright 2023 <a href="mailto:asialjim@hotmail.com">Asial Jim</a>
 *
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 */
package com.asialjim.encommunicate.rsa.server.config;

import com.asialjim.encommunicate.rsa.management.pojo.AppEnDecryptInfo;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;

import java.io.Serial;
import java.io.Serializable;
import java.util.List;
import java.util.Optional;

/**
 * RSA 加密配置属性
 *
 * @author Copyright © <a href="mailto:asialjim@hotmail.com">Asial Jim</a>   Co., LTD
 * @version 1.0
 * @since 2023/2/28, &nbsp;&nbsp; <em>version:1.0</em>, &nbsp;&nbsp; <em>java version:17</em>
 */
@Data
@ConfigurationProperties(RSAConfigProperty.YAML_PROPERTIES_PREFIX)
public class RSAConfigProperty implements Serializable {
    @Serial
    private static final long serialVersionUID = 766344328668716082L;
    public static final String YAML_PROPERTIES_PREFIX = "security";

    private Boolean enable;
    private String name;
    private Integer order;

    private List<String> urlPatterns;
    private List<AppEnDecryptInfo> apps;

    public Boolean getEnable() {
        return Optional.ofNullable(enable).orElse(Boolean.FALSE);
    }

    public Integer getOrder() {
        return Optional.ofNullable(this.order).orElse(Integer.MIN_VALUE);
    }
}